<!--

Saherace - Rent a Car

This page shows all car details of a selected car. The customer
has the possibility to choose this car for a rental.

-->

<!-- Include the soap client connection and the header area of the website -->
<?php include('includes/header.php'); ?>
	
	<?php
	
	//Save the selected car in a session variable to use it later again
	if (isset($_GET['car_id']))
		$_SESSION['car_id'] = $_GET['car_id'];
	
	//Create parameter array for calling a webservice method
	$car_id = array('id'=> $_SESSION['car_id']);
	
	//Get all details of a specific car
	$getCarDetails = $client->getCarDetails($car_id);
	
	//Get the avarage rate of a specific car
	$getAverageRate = $client->getAverageRate($car_id);
	?>
	
	<!-- List all attributes of a the selected car -->
	<ul data-role="listview" data-inset="true">
			<li data-role="list-divider"><?php echo $getCarDetails->return->brand . " " . $getCarDetails->return->model; ?></li>
			<li>
				<table>
					<tr>
						<!-- The image is returned as byte array -->
						<td colspan="2" style="text-align:center;"><?php echo '<img width="250" src="data:image/jpeg;base64,'.base64_encode($getCarDetails->return->photo).'" />'; ?></td>
					</tr>
					<tr>
						<td width="150">Preis pro Tag:</td>
						<td><?php echo $getCarDetails->return->price; ?> ,- EUR/Tag</td>
					</tr>
					<tr>
						<!-- The rate is shown as star. 1 is one star - 5 are five stars -->
						<td width="150">Bewertung:</td>
						<td><div style="height: 15px; width: 100px; background: url(images/rating.png) no-repeat left <?php $star=(5-$getAverageRate->return)*16; echo '-'.$star.'px;' ?>; background-size: auto 80px;"></div></td>
					</tr>
					<tr>
						<td colspan="2">&nbsp;</td>
					</tr>
					<tr>
						<td>Karosserie:</td>
						<td><?php echo $getCarDetails->return->type; ?></td>
					</tr>
					<tr>
						<td>Mindestalter:</td>
						<td><?php echo $getCarDetails->return->minimum_age; ?></td>
					</tr>
					<tr>
						<td>Anzahl Sitze:</td>
						<td><?php echo $getCarDetails->return->number_seats; ?></td>
					</tr>
					<tr>
						<td>Anzahl Türen:</td>
						<td><?php echo $getCarDetails->return->number_doors; ?></td>
					</tr>
					<tr>
						<td>Getriebe:</td>
						<td><?php echo $getCarDetails->return->gear_type; ?></td>
					</tr>
					<tr>
						<td>Klimaanlage:</td>
						<td><?php if($getCarDetails->return->air_conditioner) echo "ja"; else echo "nein"; ?></td>
					</tr>
				</table>
			</li>
	</ul>
	
	<!-- Link to next step "Login" -->
	<a href="login.php" data-role="button" data-icon="arrow-r" data-iconpos="right">Reservieren</a>	

<!-- Include the footer area of the website -->
<?php include('includes/footer.php'); ?>
